T = [[3, 104, 98],
    [2, 100, 93],
    [1, 81, 95],
    [101, 10, 16],
    [99, 5, 8],
    [98, 2, 7]]

x=[18,90]

k=3
dis=[]
from math import sqrt
for i in T:
    d=sqrt((x[0]-i[0])**2+(x[1]-i[1])**2)
    dis.append([d,i[2]])

dis.sort(key=lambda x:x[0])

sum=0
print(dis)
for i in dis[0:k]:
    sum+=i[1]

print(sum/k)